import React, { Component } from 'react'
import { Upload, Button } from 'antd';
export default class Customer extends React.Component {

    render() {
        this.state = {
            organCertUrl: "",//用来存放图片地址的对象
        }
        //------------------------------------定义上传图片的参数----------------------------------------
        const $this = this
        const props = {
            ref: "upload",
            action: '/house/saveImages', //这块是将后台给你的接口地址需要改一下你自己的交互地址
            listType: 'picture',
            data:{},
            className: 'upload-list-inline',
            onChange({ file, fileList }) {//file,和fileList是组件自带的参数，根据你上面赋值过去的接口给你返回的内容，file是个对象，fileList是个数组，其实file对象就相当于你用axios方法返回的response对象差不多啦~
                if (file.status === 'done') {
                    $this.setState({ organCertUrl: file.response.result, })//前面是我的存放地址的对象
                }
            }
        }

        return (
            <div>
                <div key={Math.random()}>
                    <Upload {...props} defaultFileList={this.state.fileList}>
                        <Button onClick={this.upLoadImg}>
                            上传
                        </Button>
                    </Upload>
                </div>
            </div>
        )
    }
}